"use strict";

const { logger } = require("ee-core/log");
const { ChildJob, ChildPoolJob } = require("ee-core/jobs");

const { douyinService } = require("../service/douyin");

/**
 * douyin
 * @class
 */
class DouyinController {
  constructor() {
    // 在构造函数中初始化一些变量
    this.myTimer = null;
    this.myJob = new ChildJob();
    this.myJobPool = new ChildPoolJob();
    this.taskForJob = {};
  }

  /**
   * 任务
   */
  async someJob(args, event) {
    const { jobId, action } = args;
    let result;
    switch (action) {
      case "create":
        result = await douyinService.doJob(jobId, action, event);
        break;
      case "close":
        douyinService.doJob(jobId, action, event);
        break;
      case "pause":
        douyinService.doJob(jobId, action, event);
        break;
      case "resume":
        douyinService.doJob(jobId, action, event);
        break;
      default:
    }

    let data = {
      jobId,
      action,
      result,
    };
    return data;
  }
  /**
   * test
   */
  async test() {
    return "hello electron-egg";
  }
}
DouyinController.toString = () => "[class DouyinController]";

module.exports = DouyinController;
